package com.jye.rseven.user.controller;

import com.jye.rseven.user.util.FileUpload;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
@Api(tags="上传文件控制器API")
@CrossOrigin
public class UploadController {

    @RequestMapping("/fileUpload")
    @ApiOperation(value="上传文件", notes="上传文件")
    public String fileUpload(@RequestParam("file")MultipartFile file){
        if(file==null){
            return "null";
        }
        String imgUrl = FileUpload.uploadImage(file);
        return imgUrl;
    }
}
